
********************************************************************************************************************************
**** Results for manuscript 'Threat and parochialism in intergroup relations: lab-in-the-field evidence from rural Georgia' ****
********************************************************************************************************************************


// cgmwildboot.ado file needs to be installed. 
// The file is available on Doug Miller's website (http://faculty.econ.ucdavis.edu/faculty/dlmiller/statafiles/)
// The wild cluster bootstrap procedure is explained in:Cameron, A. Colin, Jonah B. Gelbach, and Douglas L. Miller. 2008. 
// ‘Bootstrap-Based Improvements for Inference with Clustered Errors’. Review of Economics and Statistics 90 (3): 414–27. 


// Path, change as necessary:
cd "path-to-folder-containing-data"
use "./manuscript_data.dta"", clear


// Results reported in Figure 2/Table S2
cgmwildboot pt_t_neigh exposure p_neigh pgg_neigh age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot pt_pgg_comm exposure age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot pt_p_neigh exposure pgg_neigh age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot percbias_t exposure p_neigh pgg_neigh  age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot percbias_pgg exposure age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot percbias_p exposure pgg_neigh age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 



// Results reported in Figure 3
* T-role spending, absolute 
logistic high_pggneigh c.pt_t_neigh##c.pt_t_neigh##c.pt_t_neigh age sqage mistakes p_neigh if exposure==1, cluster(village)
margins, at(pt_t_neigh==(0 (20) 100)) post
logistic high_pggneigh c.pt_t_neigh age sqage mistakes p_neigh if exposure==0, cluster(village)
margins, at(pt_t_neigh==(0 (20) 100)) post
*T-role spending, bias
logistic high_pggneigh percbias_t age sqage mistakes p_neigh if exposure==1, cluster(village)
margins, at(percbias_t==(-30 (20) 70)) post
logistic high_pggneigh percbias_t age sqage mistakes p_neigh if exposure==0, cluster(village)
margins, at(percbias_t==(-60 (20) 100)) post


// P-values for Table S1
preserve
collapse (mean) share_outgroup neigh_pop100 neigh_distance t_comm exposure, by(village) 
foreach var of varlist share_outgroup neigh_pop100 neigh_distance {
ranksum `var', by(exposure)
}
restore
foreach var of varlist gender age born edu hhincome church_attendance t_comm t_neigh pgg_comm pgg_neigh  p_comm p_neigh {
ranksum `var', by(exposure)
}


// Results reported in Table S3
cgmwildboot pt_t_neigh share_outgroup p_neigh pgg_neigh age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot pt_pgg_comm share_outgroup age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot pt_p_neigh share_outgroup pgg_neigh age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot percbias_t share_outgroup p_neigh pgg_neigh  age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot percbias_pgg share_outgroup age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot percbias_p share_outgroup pgg_neigh age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 


// Results reported in text
cgmwildboot pt_pgg_comm aggressive age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
cgmwildboot percbias_pgg aggressive age sqage mistakes, cluster(village) bootcluster(village) reps(5000) 
